#!/bin/bash
s1_goto_dir(){
	local target_dir=$1
	cd "$target_dir" || return 1
	echo "已进入目录: $target_dir"
}
s2_touch_empty_file_with_given_name(){
	local file_name=$1
	touch "$file_name"
	if [ -f "$file_name" ]; then
		echo "已创建空文件: $file_name"
	else
		echo "创建空文件 $file_name 失败"
	fi
}
s3_make_directories(){
	local dir_name=$1
	mkdir -p "$dir_name"
	if [ -d "$dir_name" ]; then
		echo "已创建目录: $dir_name"
	else
		echo "创建目录 $dir_name 失败"
	fi
}
s4_create_6_files(){
	for i in{1..6};do
		touch "file$i.txt"
		if [ -f "files$i.txt" ]; then
			echo "已创建文件: file$i.txt"
		else
			echo "创建文件 file$i.txt 失败"
		fi
	done
}
s5_make_directories_in_git() {
    local sub_dir=$1
    mkdir -p "git/$sub_dir"
    if [ -d "git/$sub_dir" ]; then
        echo "已在git目录下创建目录: git/$sub_dir"
    else
        echo "在git目录下创建目录 git/$sub_dir 失败"
    fi
}
s6_move_files_to_dir_1_or_2() {
    mkdir -p dir1 dir2
    local count=1
    for file in file*.txt; do
        if [ $((count % 2)) -eq 1 ]; then
            mv "$file" dir1/
            echo "已将 $file 移动到 dir1"
        else
            mv "$file" dir2/
            echo "已将 $file 移动到 dir2"
        fi
        ((count++))
    done
}
s7_create_package_and_compress() {
    local package_name=$1
    tar -czvf "$package_name" git
    if [ -f "$package_name" ]; then
        echo "已创建并压缩包: $package_name"
    else
        echo "创建并压缩包 $package_name 失败"
    fi
}
s8_delete_dir_git() {
    if [ -d "git" ]; then
        rm -rf git
        echo "已删除git目录"
    else
        echo "git目录不存在，无需删除"
    fi
}
s9_recover_from_git_tar_gz_backup() {
    local backup_file=$1
    if [ -f "$backup_file" ]; then
        tar -zxvf "$backup_file"
        echo "已从 $backup_file 恢复"
    else
        echo "备份文件 $backup_file 不存在，无法恢复"
    fi
}
s10_create_package_and_compress() {
    local package_name=$1
    tar -jcvf "$package_name" git
    if [ -f "$package_name" ]; then
        echo "已创建并压缩包: $package_name"
    else
        echo "创建并压缩包 $package_name 失败"
    fi
}
s11_find_and_sort_alphabetically_all_created_files_and_dirs() {
    find . | sort
}
s12_get_next_15_minutes_boundary() {
    current_minute=$(date +%M)
    next_15_minute=$(( ( ( (current_minute + 14) / 15 ) * 15 ) - current_minute ))
    date -d "+$next_15_minute minutes" +"%Y-%m-%d_%H:%M:%S"
}
